﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="handsontable-jquery-handsontable-6260dd0/lib/jquery.min.js"></script>
    <script src="handsontable-jquery-handsontable-6260dd0/dist/jquery.handsontable.full.js"></script>
    <link href="handsontable-jquery-handsontable-6260dd0/dist/jquery.handsontable.full.css" rel="stylesheet" />
 
    <link rel="canonical" href="http://handsontable.com/demo/ajax.html" />
    <style>
        .pagerLink{
            background:#b9b3b6;
            color: #010b11;
            padding: 4px;
        }
        .pagerLink .active{
            background:#808080;
            color: #fff;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div>
            <table>
                <tr><td>Estudiante</td><td><input id="txtEstudiante" /></td></tr>
                <%--<tr><td>IDEstudiante</td><td><input id="txtIDEstudiante" /></td></tr>--%>
                <tr><td colspan="2"><button id="btnSearch">Search</button></td></tr>
            </table>
        </div>
        <div id="newgrid" class="dataTable" style="height: 500px;">
        </div>
        <div id="pager">

        </div>
        <script>
            function loadData(page) {
                var criteria = {
                    page: page,
                    name: $('#txtEstudiante').val()
                }
                $.ajax({
                    url: "WebService.asmx/GetExamenData",
                    type: "POST",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(criteria),
                    success: function (rs) {
                        var data = $.parseJSON(rs.d? rs.d: rs);
                        $('#newgrid').handsontable('loadData', data.data);
                    }
                });
            }

            $(function () {
                var data = [];
                var columns = ["Asignaturas", "IDAsignatura", "IExamenI", "IExamenII", "IExamenIII", "IIExamenI", "IIExamenII", "IIExamenIII", "IExamenIV", "IIExamenIV", "CPFS_I", "CPFS_II", "CFS_I", "CFS_II", "CF", "PCP", "PCP70", "CPFS", "CPSF30", "CFS", "IPCP50", "ICPC_Completiva", "ICPC50", "ICC", "IPCP30", "ICPEX_Extraordinaria", "ICPEX70", "ICEX", "IIPCP", "IIPCP70", "IICPFS", "IICPSF30", "IICFS", "IIPCP50", "IICPC_Completiva", "IICPC50", "IICC", "IIPCP30", "IICPEX_Extraordinaria", "IICPEX70", "IICEX", "IDExamen", "IDProfesor"];
                $('#btnSearch').on('click', function (e) {
                    e.preventDefault();
                    loadData(0);
                });
                $('#newgrid').handsontable({
                    rowHeaders: false,
                    
                    colHeaders: columns,
                    minSpareRows: 1, startRows: 5,
                    startCols: 42,
                    contextMenu: false,
                    afterChange: function (changes, source) {
                        if (source == 'loadData') { return; }

                       
                        //$('#simple').val(JSON.stringify(rowList));
                        //console.log(rowList);
                        //var data = JSON.stringify(rowList);


                        ////var textbox = document.getElementById('txtData');
                        ////textbox.value = data;
                        //if (data.length != "") {
                        //    $.ajax({
                        //        url: "WebService.asmx/SaveExamenData",
                        //        type: "POST",
                        //        dataType: "json",
                        //        contentType: "application/json; charset=utf-8",
                        //        data: '{"data":"' + argsRow + '"}',
                        //        success: function (response) {

                        //        }
                        //    });
                        //}
                    }
                });
                loadData(0);
            });
        </script>
        <%--<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1">
            <Columns>
                <asp:BoundField DataField="Asignaturas" HeaderText="Asignaturas" SortExpression="Asignaturas" />
                <asp:BoundField DataField="IDAsignatura" HeaderText="IDAsignatura" SortExpression="IDAsignatura" />
                <asp:BoundField DataField="IExamenI" HeaderText="IExamenI" SortExpression="IExamenI" />
                <asp:BoundField DataField="IExamenII" HeaderText="IExamenII" SortExpression="IExamenII" />
                <asp:BoundField DataField="IExamenIII" HeaderText="IExamenIII" SortExpression="IExamenIII" />
                <asp:BoundField DataField="IIExamenI" HeaderText="IIExamenI" SortExpression="IIExamenI" />
                <asp:BoundField DataField="IIExamenII" HeaderText="IIExamenII" SortExpression="IIExamenII" />
                <asp:BoundField DataField="IIExamenIII" HeaderText="IIExamenIII" SortExpression="IIExamenIII" />
                <asp:BoundField DataField="IExamenIV" HeaderText="IExamenIV" SortExpression="IExamenIV" />
                <asp:BoundField DataField="IIExamenIV" HeaderText="IIExamenIV" SortExpression="IIExamenIV" />
                <asp:BoundField DataField="CPFS_I" HeaderText="CPFS_I" SortExpression="CPFS_I" />
                <asp:BoundField DataField="CPFS_II" HeaderText="CPFS_II" SortExpression="CPFS_II" />
                <asp:BoundField DataField="CFS_I" HeaderText="CFS_I" SortExpression="CFS_I" />
                <asp:BoundField DataField="CFS_II" HeaderText="CFS_II" SortExpression="CFS_II" />
                <asp:BoundField DataField="CF" HeaderText="CF" SortExpression="CF" />
                <asp:BoundField DataField="PCP" HeaderText="PCP" SortExpression="PCP" />
                <asp:BoundField DataField="PCP70" HeaderText="PCP70" SortExpression="PCP70" />
                <asp:BoundField DataField="CPFS" HeaderText="CPFS" SortExpression="CPFS" />
                <asp:BoundField DataField="CPSF30" HeaderText="CPSF30" SortExpression="CPSF30" />
                <asp:BoundField DataField="CFS" HeaderText="CFS" SortExpression="CFS" />
                <asp:BoundField DataField="IPCP50" HeaderText="IPCP50" SortExpression="IPCP50" />
                <asp:BoundField DataField="ICPC_Completiva" HeaderText="ICPC_Completiva" SortExpression="ICPC_Completiva" />
                <asp:BoundField DataField="ICPC50" HeaderText="ICPC50" SortExpression="ICPC50" />
                <asp:BoundField DataField="ICC" HeaderText="ICC" SortExpression="ICC" />
                <asp:BoundField DataField="IPCP30" HeaderText="IPCP30" SortExpression="IPCP30" />
                <asp:BoundField DataField="ICPEX_Extraordinaria" HeaderText="ICPEX_Extraordinaria" SortExpression="ICPEX_Extraordinaria" />
                <asp:BoundField DataField="ICPEX70" HeaderText="ICPEX70" SortExpression="ICPEX70" />
                <asp:BoundField DataField="ICEX" HeaderText="ICEX" SortExpression="ICEX" />
                <asp:BoundField DataField="IIPCP" HeaderText="IIPCP" SortExpression="IIPCP" />
                <asp:BoundField DataField="IIPCP70" HeaderText="IIPCP70" SortExpression="IIPCP70" />
                <asp:BoundField DataField="IICPFS" HeaderText="IICPFS" SortExpression="IICPFS" />
                <asp:BoundField DataField="IICPSF30" HeaderText="IICPSF30" SortExpression="IICPSF30" />
                <asp:BoundField DataField="IICFS" HeaderText="IICFS" SortExpression="IICFS" />
                <asp:BoundField DataField="IIPCP50" HeaderText="IIPCP50" SortExpression="IIPCP50" />
                <asp:BoundField DataField="IICPC_Completiva" HeaderText="IICPC_Completiva" SortExpression="IICPC_Completiva" />
                <asp:BoundField DataField="IICPC50" HeaderText="IICPC50" SortExpression="IICPC50" />
                <asp:BoundField DataField="IICC" HeaderText="IICC" SortExpression="IICC" />
                <asp:BoundField DataField="IIPCP30" HeaderText="IIPCP30" SortExpression="IIPCP30" />
                <asp:BoundField DataField="IICPEX_Extraordinaria" HeaderText="IICPEX_Extraordinaria" SortExpression="IICPEX_Extraordinaria" />
                <asp:BoundField DataField="IICPEX70" HeaderText="IICPEX70" SortExpression="IICPEX70" />
                <asp:BoundField DataField="IICEX" HeaderText="IICEX" SortExpression="IICEX" />
                <asp:BoundField DataField="IDExamen" HeaderText="IDExamen" SortExpression="IDExamen" />
                <asp:BoundField DataField="IDProfesor" HeaderText="IDProfesor" SortExpression="IDProfesor" />
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="DataSetTableAdapters.Func_ExamenTableAdapter">
            <SelectParameters>
                <asp:SessionParameter Name="IDSession" SessionField="IDSession" Type="Int32" />
                <asp:SessionParameter Name="IDEstudiante" SessionField="IDEstudiante" Type="Int32" />
                <asp:SessionParameter Name="Bachillerato" SessionField="Bachiller" Type="Boolean" />
            </SelectParameters>
        </asp:ObjectDataSource>--%>
    
    </div>
    </form>
</body>
</html>
